package com.yss.common.core.enums;

import com.yss.common.core.utils.StringUtils;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 状态的标识
 *
 * @author lsl
 */
@Getter
@AllArgsConstructor
public enum YssStatusEnum implements BaseEnum<Integer> {
    NORMAL(1, "启用"),
    DELETED(2, "停用"),
    WAITING_REVIEW(3, "待审核"),
    UNDER_REVIEW(4, "审核中"),
    FAIL_REVIEW(5, "审核不通过");

    private final Integer code;
    private final String desc;

    public static YssStatusEnum getEnum(Integer code) {
        return Arrays.stream(values()).filter(b -> b.code == code).findFirst().orElse(null);
    }

    public static String getEnumDesc(Integer code) {
        YssStatusEnum e = getEnum(code);
        return e != null ? e.desc : null;
    }

    /**
     * 升级工具需要的数据状态类型 只有1 正常 和2 已删除
     *
     * @return
     */
    public static List<Integer> getUpgradeToolsZipStatus() {
        List<Integer> list = new ArrayList<>();
        for (YssStatusEnum statusEnum : YssStatusEnum.values()) {
            if (StringUtils.isNull(statusEnum)) {
                continue;
            }
            if (1 == statusEnum.getCode() || 2 == statusEnum.getCode()) {
                list.add(statusEnum.getCode());
            }
        }
        return list;

    }
}
